#include<bits/stdc++.h>
#define int long long
#define il inline
#define ct const
#define dl double
#define pk push_back
#define fi first
#define se second
#define pii pair<int,int>
#define N 1000010
using namespace std;
il int read(){
	int x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){
		if(ch=='-') f=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9'){
		x=(x<<1)+(x<<3)+(ch^48);ch=getchar();
	}
	return x*f;
}
char f__[40];
il void write(int x){
	int cnt=0;
	if(x<0){
		putchar('-');x=-x;
	}
	if(!x) putchar('0');
	while(x){
		f__[cnt++]=x%10+'0';x/=10;
	}
	while(cnt) putchar(f__[--cnt]);
}
int head[N],nxt[N<<1],to[N<<1],t;
il void add(int u,int v){
    nxt[++t]=head[u];head[u]=t;to[t]=v;
    nxt[++t]=head[v];head[v]=t;to[t]=u;
}
int n,f[N];
bool vis[N];
il void dfs1(int x,int fa){
    f[x]=fa;
    for(int i=head[x];i;i=nxt[i]) if(to[i]!=fa) dfs1(to[i],x);
}
vector<int> V;
signed main(){
	freopen("choice.in","r",stdin);
	freopen("choice.out","w",stdout);
    n=read();
    for(int i=1;i<n;++i) add(read(),read());
    dfs1(1,0);vis[0]=1;
    for(int i=1;i<=n;++i){
        V.clear();
        for(int j=i;!vis[j];j=f[j]){
            vis[j]=1;V.pk(j);
        }
        reverse(V.begin(),V.end());
        for(auto v:V){
            write(v);putchar(' ');
        }
    }
	return 0;
}